package 第一讲基础算法;

import java.util.Scanner;

public class AcWing801 {
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		while(n-->0) {
			int x=sc.nextInt();
			int cnt=0;
			while(x>0) {
				x-=lowbit(x);
				cnt++;
			}
			System.out.print(cnt+" ");
		}
		sc.close();
	}
	
	public static int lowbit(int x) {
		return x&(-x);
	}

}
